//
//  VersionController.swift
//  OneMeeting
//
//  Created by zhangheng on 2019/8/9.
//  Copyright © 2019 www.zhangheng.com. All rights reserved.
//

import Foundation

class VersionController: NSViewController {
    
    override func loadView() {
        let view = NSView.init(frame: NSRect.init(x: 0, y: 0, width: kVersionWinWidth, height: kVersionWinHeight))
        view.wantsLayer = true
        view.layer?.backgroundColor = color_gray(237).cgColor
        self.view = view
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
        loadData()
    }
    
    func setupUI() {
        
        self.view.addSubview(logoImageV)
        logoImageV.snp.makeConstraints { (make) in
            make.width.height.equalTo(60)
            make.centerX.equalToSuperview()
            make.top.equalTo(10)
        }
        
        self.view.addSubview(nameLab)
        nameLab.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(logoImageV.snp.bottom).offset(10)
            make.width.equalToSuperview()
            make.height.equalTo(20)
        }
        
        self.view.addSubview(versionLab)
        versionLab.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(nameLab.snp.bottom).offset(10)
            make.width.equalToSuperview()
            make.height.equalTo(20)
        }
        
        self.view.addSubview(buildLab)
        buildLab.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(versionLab.snp.bottom).offset(0)
            make.width.equalToSuperview()
            make.height.equalTo(14)
        }
        
        self.view.addSubview(buildLab2)
        buildLab2.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(buildLab.snp.bottom).offset(0)
            make.width.equalToSuperview()
            make.height.equalTo(14)
        }
    }
    
    func loadData() {
        self.versionLab.stringValue = "版本".localized()+AppInfo.majorVersion()+"("+AppInfo.minorVersion()+")"
    }
    
    lazy var nameLab: NSTextField = {
        let lab = NSTextField.label(title: "壹会通".localized(), textColor: color_gray(50), font: NSFont.systemFont(ofSize: 16))
        lab.sizeToFit()
        lab.alignment = .center
        return lab
    }()
    
    lazy var versionLab: NSTextField = {
        let lab = NSTextField.label(title: "已是最新版本".localized()+"1.0.0(15)", textColor: color_gray(80), font: NSFont.systemFont(ofSize: 11))
        lab.sizeToFit()
        lab.alignment = .center
        return lab
    }()
    lazy var buildLab: NSTextField = {
        let lab = NSTextField.label(title: "Copyright©️2011-2019 "+"壹会通".localized()+" Inc.", textColor: color_gray(80), font: NSFont.systemFont(ofSize: 11))
        lab.sizeToFit()
        lab.alignment = .center
        return lab
    }()
    lazy var buildLab2: NSTextField = {
        let lab = NSTextField.label(title: "保留一切版权".localized(), textColor: color_gray(80), font: NSFont.systemFont(ofSize: 11))
        lab.sizeToFit()
        lab.alignment = .center
        return lab
    }()
    
    lazy var logoImageV: NSImageView = {
        let imageV = NSImageView.init(image: NSImage.init(named: NSImage.Name.init("logo_128"))!)
        return imageV
    }()
    
    @objc func closeBtnAction(senber:LLCustomBtn) -> () {
        NSApplication.shared.stopModal()
    }
    
    
}
